<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>任务项查询（查询之前需要先输入项目编号）</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="proCode">项目编号</label>
                                    <select id="proCode" class="form-control" name="proCode"
                                            style="width: 175px;"></select>
                                    <input type="text" id="rwId" th:value="${proCode}" class="form-control"
                                           name="proCodeQuery" readonly>
                                </div>
                                <div class="form-group">
                                    <label for="proName">项目名称</label>
                                    <input id="proName" type="text" th:value="${proName}" name="proName"
                                           class="form-control" readonly>
                                </div>
                                <div class="form-group">
                                    <label for="query-section">科室</label>
                                    <input id="query-section" type="text" name="deptName" class="form-control"
                                           placeholder="请输入科室">
                                </div>
                                <div class="form-group">
                                    <label for="query-tasker">负责人</label>
                                    <input id="query-tasker" type="text" name="taskerName" class="form-control"
                                           placeholder="请输入负责人">
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"><span
                                        class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    $(function () {

        if ([[${proCode}]] != null && [[${proCode}]] != '') {
            $("#proCode").hide();
        } else {
            $("#rwId").hide();
            /** 项目编号下拉框 */
            js.select2({
                id: 'proCode',
                placeholder: '',
                ajax: {
                    url: function () {
                        return ctx + 'designTask/gant/project/list'
                    },
                    processResults: function (data, page) {
                        let array = data;
                        for (let i = 0; i < data.length; i++) {
                            array[i]["id"] = array[i]['code'];
                            array[i]["text"] = array[i]['code'];
                        }
                        return {results: array};
                    },
                }
            });
        }

        /** 项目编号下拉框选中 */
        $("#proCode").on("select2:select", function () {
            $("#proName").val($(this).select2("data")[0].name);
        });
        /** 项目任务计划查看 */
        table = js.table.init({
            url: ctx + "craft/proQuery/gantPage",
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName'},
                {title: "分配科室", field: 'deptName'},
                {title: "负责人", field: 'taskerName'},
                {title: "内容", field: 'content'},
                {title: "开始时间", field: 'startTime'},
                {title: "结束时间", field: 'endTime'},
                {title: "历时", field: 'diachronic'},
                {title: "备注", field: 'remark',width:'200'}
            ]
        });

        /** 表格搜索 */
        $("#btn-search").click(function () {

            if ($("#proCode").text() == "" && $("#rwId").val() == "") {
                js.modal.warning("请输入项目编号");
                return;
            }
            js.table.search(table);
        });

    });
</script>
</body>
</html>
